<div class="modal fade " id="editCommonModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document" style="width:75%">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">一级通用指标值维护</h3>
                <button type="button" class="btn btn-danger pull-right" data-dismiss="modal">关闭</button>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal">
                <div class="box">
                <div class="box-body">
                    <div id="commonQuotaToolbar" >
                        <h4 style="padding-left: 10px"><b><span id="commonScoreSpan"></span></b></h4>
                        <div class="form-inline" role="form" style="display: none">
                            <button id="addAdjust" type="button" class="btn btn-success" onclick="appAdjustCommonData()">增加调整</button>
                            <input type="hidden" id="commonCustScoreId">
                            <input type="hidden" id="commonModelVersionId">
                        </div>
                    </div>
                    <table id="editCommonQuotaTable" data-toggle="table" data-url="#"
                           data-page-size="20" data-height="600" data-search="true" data-unique-id="id" data-toolbar="#commonQuotaToolbar" >
                        <thead>
                        <tr>
                            <th data-field="index" data-formatter="indexFormatter">序号</th>
                            <th data-field="dimensionQuotaTypeName">评价维度</th>
                            <th data-field="quotaTypeName" data-formatter="quotaTypeNameFormatter">具体指标</th>
                            <th data-field="quotaValueName" data-formatter="quotaValueNameFormatter" data-align="center">指标值</th>
                            <th data-field="score">分数</th>
                        </tr>
                        </thead>
                    </table>
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="button" class="btn btn-default pull-right" data-dismiss="modal">完成</button>
                </div>
                <!-- /.box-footer -->
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    function quotaTypeNameFormatter(value, row, index){
        if(row.quotaTypeDescription == "" || row.quotaTypeDescription == null) {
            return value;
        }
        return "<a href=\"#\" data-toggle=\"tooltip\" title=\""+row.quotaTypeDescription+"\">"+value+"</a>"
    }
    function appAdjustCommonData() {
        $table = $("#editCommonQuotaTable") ;
        var custScoreId = $("#commonCustScoreId").val();
        var modelVersionId = $("#commonModelVersionId").val();
        var url = "/scoreaudit/adjust/add?modelVersionId="+modelVersionId+"&custScoreId="+custScoreId ;
        getReq(url,function (result) {
            $table.bootstrapTable("append",result);
            $table.bootstrapTable('scrollTo', 'bottom');
        }) ;
    }

    function editCommonModalInit(custScoreId,modelVersionId) {
        $("#commonCustScoreId").val(custScoreId);
        $("#commonModelVersionId").val(modelVersionId);
        $("#editCommonQuotaTable").bootstrapTable("refresh", {url: "/scoreaudit/detailInfo/list?custScoreId=" + custScoreId + "&modelVersionId="+modelVersionId});
        $("#commonScoreSpan").html("");
        var url = "/custscore/" +custScoreId;
        getReq(url, function (result) {
            if (result.success ) {
                $("#commonScoreSpan").html(removeDecimal(result.custScoreVo.commonScore) + "分");
            }
        });
    }
    function quotaValueNameFormatter(value, row, index) {
        return value.replace("tableIndex", index);
    }
    function removeDecimal( num ) {
        var str = num + "" ;
        if(str.indexOf(".") > 0) {
            return str.substring(0,str.indexOf(".")  ) ;
        } else {
            return str;
        }
    }
</script>